package com.haoshuang.zhouzhoubang.ui.page.mine.recognizance.pay.preview

import androidx.lifecycle.rxLifeScope
import com.haoshuang.zhouzhoubang.base.request
import com.haoshuang.zhouzhoubang.model.bean.BujBean
import com.haoshuang.zhouzhoubang.model.bean.BzjData
import com.haoshuang.zhouzhoubang.model.bean.WxPayBean
import com.haoshuang.zhouzhoubang.model.bean.ZfbBean
import com.mufeng.libs.base.BaseViewModel
import com.mufeng.libs.state.StateData
import com.mufeng.libs.state.StatefulMutableLiveData

class PreviewPayDepositViewModel : BaseViewModel() {
    val getData = StatefulMutableLiveData<ArrayList<BujBean>>()
    fun getData(vararg params: Pair<String, Any?>) {
        rxLifeScope.launch {
            request<ArrayList<BujBean>>("api/team/get_bu_deposit_skill_list", *params,
                onStart = {
                    getData.value = StateData.Loading
                },
                onError = { code, msg ->
                    getData.value = StateData.Error(code, msg)
                }, onSuccess = {
                    getData.value = StateData.Success(it)
                })
        }
    }
    val getData2 = StatefulMutableLiveData<ZfbBean>()
    fun getData2(vararg params: Pair<String, Any?>) {
        rxLifeScope.launch {
            request<ZfbBean>("/api/store.team/skill_create_order", *params,
                onStart = {
                    getData2.value = StateData.Loading
                },
                onError = { code, msg ->
                    getData2.value = StateData.Error(code, msg)
                }, onSuccess = {
                    getData2.value = StateData.Success(it)
                })
        }
    }
    val getData1 = StatefulMutableLiveData<BzjData>()
    fun getData1(vararg params: Pair<String, Any?>) {
        rxLifeScope.launch {
            request<BzjData>("/api/Team/team_deposit", *params,
                onStart = {
                    getData1.value = StateData.Loading
                },
                onError = { code, msg ->
                    getData1.value = StateData.Error(code, msg)
                }, onSuccess = {
                    getData1.value = StateData.Success(it)
                })
        }
    }
    val getData3 = StatefulMutableLiveData<WxPayBean>()
    fun getData3(vararg params: Pair<String, Any?>) {
        rxLifeScope.launch {
            request<WxPayBean>("/api/store.team/skill_create_order", *params,
                onStart = {
                    getData3.value = StateData.Loading
                },
                onError = { code, msg ->
                    getData3.value = StateData.Error(code, msg)
                }, onSuccess = {
                    getData3.value = StateData.Success(it)
                })
        }
    }
}